package cn.itnanls.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Max;
import java.io.Serializable;
import java.util.Date;

/**
 * @author Ding
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User implements Serializable {
    private int id;
    //数据检验的注解
    @Length(min = 2,max = 5,message = "您的名字长度不合法")
    private String username;
    private String password;
    @Max( value = 150,message = "您输入的年龄不合法")
    private int age;
    /**
     *   SpringMvc中的类型转化
     *   下面用日期来作为举例
     */
//    这个是从Json中取
    @JsonFormat(
            pattern = "yyyy年mm月dd日",
            timezone = "GMT-8"
    )
//    这个注解封装的时候参数只能从requestparamter中
    @DateTimeFormat(pattern = "yyyy年mm月dd日")
    private Date birthday;
    public User(int id, String username, String password) {
        this.id=id;
        this.username=username;
        this.password=password;
    }


}
